package com.ruoyi.supply.enums;

import lombok.Getter;

/**
 * @author huangxiong
 * @date 2025/06/05 21:29
 */
@Getter
public enum SupplyInfoStatusEnum {
    // 待审核，驳回，下架，审核通过
    WAIT_AUDIT("0","待审核",""),
    REJECT("1","驳回","0"),
    OFFLINE("2","下架","3"),
    AUDIT_PASS("3","审核通过","0");

    private final String code;
    private final String desc;
    private final String lastStatus;

    SupplyInfoStatusEnum(String code, String desc,String lastStatus) {
        this.code = code;
        this.desc = desc;
        this.lastStatus = lastStatus;
    }

    public void checkLastStatus(String lastStatus) {
        if (!this.lastStatus.equals(lastStatus)) {
            throw new IllegalStateException("当前状态不能进行此操作");
        }
    }

    public static SupplyInfoStatusEnum getByCode(String code) {
        for (SupplyInfoStatusEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

}
